#!/bin/bash

# functions

function pause(){
  read -p "$*"
}

function welcome(){
  echo -e "Welcome to einDa-skin installer."
}

function bar(){
  echo "========================================"
}

function end(){
  bar
  echo "Congratulations!!, einDa-skin was installed"
  bar
  echo "Now go to http://yourdomain:2222 and"
  echo "1 | Join admin account"
  echo "2 | Join to skin section (its usually in reseller level)"
  echo "3 | Select einDa-skin and apply to me"
  bar
  echo "Thanks for using einDa skin"
  bar
}

function join-folder(){
  cd /usr/local/directadmin/data/skins/
}

function install(){
  echo "Installing..."
  git clone https://github.com/lunadream/einDa-CN.git
  mv einDa-CN einda
  chown -R diradmin:diradmin einda
}

function update(){
  echo "Updating..."
  git pull
  chown -R diradmin:diradmin *
}

# innit

bar
welcome
bar

join-folder

directory=einda

if [ -d "$directory" ]; then
  echo "The directory einDa-skin already exists"
  echo -e "\x1B[31m == UPDATE == \x1B[0m"
  pause 'If you want update the skin, press [Enter] key for continue...'
  cd $directory/
  update
else
  pause 'Press [Enter] key for start installation...'
  install
  end
fi

